'==================================================================================================
'	Author		David Segura
'	URL			http://winpeguy.com/
'	Source		http://winpe.codeplex.com/
'	Version		20130910
'==================================================================================================
'	Purpose:
'	To determine the menu to WinPE Menu to start
'==================================================================================================
'	File Locations in Windows:
'	%DeployRoot%\Boot\+WinPE\Menu\LaunchMenu.vbs
'==================================================================================================
'	File Location in WinPE:
'	X:\Menu\LaunchMenu.vbs
'==================================================================================================
'	Configuration:
'	None.  Editing this file is not recommended
'==================================================================================================
'	Change Log:
'	20130910	Codeplex Beta
'==================================================================================================
Option Explicit

'Declare Variables
Dim objFSO, WshShell, WshNetwork, objShell
	Set objFSO = CreateObject("Scripting.FileSystemObject") 
	Set WshShell = WScript.CreateObject("WScript.Shell")
	Set WshNetwork = WScript.CreateObject("WScript.Network")
	Set objShell = WScript.CreateObject("WScript.Shell")
'==================================================================================================
Dim strComputer, objWMIService
	strComputer = "."	
	Set objWMIService = GetObject( _
	    "winmgmts:\\" & strComputer & "\root\CIMV2")
'==================================================================================================
Dim objRegistry
	Set objRegistry = GetObject("winmgmts:\\" & _ 
	    strComputer & "\root\default:StdRegProv")
    
	Const HKEY_CLASSES_ROOT			= &H80000000
	Const HKEY_CURRENT_USER			= &H80000001
	Const HKEY_LOCAL_MACHINE		= &H80000002
	Const HKEY_USERS				= &H80000003
	Const HKEY_CURRENT_CONFIG		= &H80000005
'==================================================================================================
'Gather Environment Variables
Dim envComputerName, envProcessorArchitecture, envSystemDrive, envUserName, envSystemRoot, envSystem32, strMenuDir
	envComputerName = WshShell.ExpandEnvironmentStrings("%ComputerName%")
	envProcessorArchitecture = WshShell.ExpandEnvironmentStrings("%PROCESSOR_ARCHITECTURE%")	'Will return x86 or AMD64
	envSystemDrive = WshShell.ExpandEnvironmentStrings("%SystemDrive%")
	envUserName = WshShell.ExpandEnvironmentStrings("%UserName%")
	envSystemRoot = WshShell.ExpandEnvironmentStrings("%Windir%")
	envSystem32 = envSystemRoot & "\System32"
	strMenuDir = "X:\Menu"
'==================================================================================================
Dim sCmd
Dim strKeyPath, strValueName, strValue


'Launch Menu
	If objFSO.FileExists(strMenuDir & "\Menu-Custom.hta") Then
		sCmd = "mshta.exe " & strMenuDir & "\Menu-Custom.hta"
		objShell.Run sCmd
	ElseIf objFSO.FileExists(envSystemDrive & "\sources\recovery\tools\MSDartTools.exe") Then
		sCmd = "mshta.exe " & strMenuDir & "\Menu-DaRT.hta"
		objShell.Run sCmd
	ElseIf objFSO.FileExists(strMenuDir & "\Menu.hta") Then
		sCmd = "mshta.exe " & strMenuDir & "\Menu.hta"
		objShell.Run sCmd
	End If
'==================================================================================================